package java_常用api;

public class API_7_高级数组操作_快速排列 {
    public static void main(String[] args) {
        int[] list = {6,1,2,7,9,3,4,5,10,8};
        sort(list,0,list.length-1);
        for (int i = 0; i < list.length; i++) {
            System.out.print(list[i]);
        }
    }

    private static void sort(int[] list, int left, int right) {
        int left0 = left;
        int right0 = right;

        //算出计数

        int jishu = list[left];
        while (left != right){
            // 右边比计数小的
            while (list[right] >= jishu && right >left){
                right--;
            }
            //左边比计数大的
            while (list[left] <= jishu && right >left){
                left++;
            }
            // 交换值
            int xx = list[left];
            list[left] = list[right];
            list[right] = xx;

        }
        int xx = list[left];
        list[left] = list[right];
        list[left0] =xx;


    }
}

